package org.goodprinciples.oracolo.model;

import java.io.Serializable;
import java.util.Objects;
import org.goodprinciples.commons.bean.CodeDescriptionBean;

/**
 *
 * @author Francesco Conte
 */
public class Association extends OracoloBean<Association> {
    
    private AssociationId id = null;
    private NullableType nullableType = null;
    private Domain domain = null;
    
    public Association() {}

    public Domain getDomain() {
        return domain;
    }

    public void setDomain(Domain domain) {
        this.domain = domain;
    }

    public AssociationId getId() {
        return id;
    }

    public void setId(AssociationId id) {
        this.id = id;
    }

    public NullableType getNullableType() {
        return nullableType;
    }

    public void setNullableType(NullableType nullableType) {
        this.nullableType = nullableType;
    }

    public boolean equals(java.lang.Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Association other = (Association) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        return true;
    }

    public int hashCode() {
        int hash = 7;
        hash = 89 * hash + Objects.hashCode(this.id);
        return hash;
    }

    public String toString() {
        return "Association{" + "id=" + id + ", nullableType=" + nullableType + ", domain=" + domain + '}';
    }
    
    public static enum NullableType implements CodeDescriptionBean {
        
        NULLABLE("Y", "Nullabe value"),
        NOT_NULLABLE("N", "Not nullable value"),
        ;
        
        private String code = null;
        private String description = null;
        
        private NullableType(String code, String description) {
            this.code = code;
            this.description = description;
        }

        @Override
        public String getCode() {
            return code;
        }

        @Override
        public String getDescription() {
            return description;
        }

        public String toString() {
            return "NullableType{" + "code=" + code + ", description=" + description + '}';
        }
        
    }
    
    public static class AssociationId implements Serializable {
        
        private Property property = null;
        private Object object = null;
        
        public AssociationId() {}

        public Object getObject() {
            return object;
        }

        public void setObject(Object object) {
            this.object = object;
        }

        public Property getProperty() {
            return property;
        }

        public void setProperty(Property property) {
            this.property = property;
        }

        public boolean equals(java.lang.Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final AssociationId other = (AssociationId) obj;
            if (!Objects.equals(this.property, other.property)) {
                return false;
            }
            if (!Objects.equals(this.object, other.object)) {
                return false;
            }
            return true;
        }

        public int hashCode() {
            int hash = 7;
            hash = 97 * hash + Objects.hashCode(this.property);
            hash = 97 * hash + Objects.hashCode(this.object);
            return hash;
        }

        public String toString() {
            return "AssociationId{" + "property=" + property + ", object=" + object + '}';
        }
        
    }
    
}
